{include file="public/header" /}
<style>
    .layui-form-select dl dd {
        text-align: center;
    }
    .layui-form-select .layui-input {
        border: none;
        padding-left: 0 !important;
        text-align: right;
        width: 100%;
    }
    .layui-form-select {
        width: 80%;
    }
</style>
<body class="hide-top bgc">
<div class="draw-container">
    <img src="/static/index/img/icon18.png" alt="">
    <div class="draw-content">
        <div class="draw-hd">
            <i class="layui-icon layui-icon-left" onclick="load_href('{:url(\'user/index\')}',2)"></i> 转账
        </div>
        <form action="{:url('transfer/save')}" method="post" class="form layui-form">
            <div class="transfer-content">
                <ul class="transfer-list">
                    <li style="display: flex;align-items: center;">
                        <p>转账账户</p>
                        <select name="account" lay-verify="required" lay-reqtext="请选择账户">
                            <option value="currency">{:get_pay_way('currency')}(余额:{$user.assets.currency})</option>
                        </select>
                    </li>
                    <li>
                        <p>收账会员</p>
                        <input type="text" name="take" id="take" lay-verify="required" lay-reqtext="请输入收账会员编号"
                               placeholder="请输入收账会员编号" autocomplete="off">
                    </li>
                    <li class="take_info" style="display: none">
                        <p>收账会员昵称</p>
                        <input type="text" id="take_nickname" readonly>
                    </li>
                    {if $system.transfer_cost > 0}
                    <li>
                        <p>手续费</p>
                        <input type="text" value="{$system.transfer_cost*100}%" readonly>
                    </li>
                    {/if}
                    <li>
                        <p>转账金额</p>
                        <input type="number" name="amount" id="amount" lay-verify="required" lay-reqtext="请输入转账金额"
                               placeholder="请输入转账金额，{$system.transfer_min}起" autocomplete="off">
                    </li>
                    <li class="real_amount" style="display: none;">
                        <p>实际到账金额</p>
                        <input type="text" id="real_amount" readonly>
                    </li>
                    <li>
                        <p>支付密码</p>
                        <input type="password" name="pay_password" lay-verify="required" lay-reqtext="请输入支付密码"
                               placeholder="请输入支付密码">
                    </li>
                </ul>
            </div>
            <p class="save upd-save" lay-submit lay-filter="save" formObj=".form">确认转账</p>
        </form>
        <div class="flex-center">
            <a href="{:url('transfer/record')}" class="transfer-rec">转账记录
                <img src="/static/index/img/icon20.png" alt="">
            </a>
        </div>
    </div>
</div>
</body>
{include file="public/footer" /}
<script>
    $(function () {
        $('#take').blur(function () {
            var value = $(this).val();
            if (value) {
                $.ajax({
                    type: 'GET',
                    url: '{:url("index/inquiryUser")}',
                    data: {code: value, type: 'code'},
                    dataType: "json",
                    success: function (data) {
                        $(".take_info").show();
                        if (data.code === 1) {
                            $("#take_nickname").val(data.data.nickname);
                        } else {
                            $("#take_nickname").val(data.msg);
                        }
                    }
                });
            }else{
                $(".take_info").hide();
            }
        });
        $('#amount').blur(function () {
            var value = $(this).val();
            if (value) {
                var cost = "{$system.transfer_cost}";
                amount = (parseFloat(value) * (1 - parseFloat(cost))).toFixed(2);
                $('#real_amount').val(amount);
                $(".real_amount").show();
            } else {
                $(".real_amount").hide();
            }
        });
    });
</script>
</html>